<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class PictureCategory extends Model
{
    use HasDateTimeFormatter;

    protected $table = 'picture_category';

    protected $primaryKey = 'cate_id';

    public function picture()
    {
        return $this->hasMany(Picture::class, 'cate_id', 'cate_id');
    }

    public function getList($where = [], $with = [], $select = ['*'])
    {
        return $this->newQuery()
            ->when($with, function ($query, $with) {
                return $query->with($with);
            })
            ->select($select)
            ->where($where)
            ->orderBy('sort')
            ->get();
    }

}
